﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Marmat.Foundation;
using Marmat.Template.WinForm;
using Marmat.FrameWork;
using 测试项目.NewFolder1;

namespace 测试项目.TestDemo
{
    public partial class TestFirstDemoViewForm : Form, Marmat.Template.WinForm.IDocumentViewForm<TestDemoEntity>, Marmat.Foundation.IViewFormPanelBatchAction
    {

        private RelationProvider<TestDemoEntity> class1 = new RelationProvider<TestDemoEntity>();
        public TestFirstDemoViewForm()
        {
            InitializeComponent();

        }

        public IDocumentViewFormController<TestDemoEntity, TestDemoEntity[]> Controller { get; set; }

        void IDocumentViewForm<TestDemoEntity, TestDemoEntity[]>.Load(TestDemoEntity[] data)
        {
            this.gridControl1.DataSource = data;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.Controller.Management.ShowEditForm("1");
        }

        void IViewFormPanelBatchAction.Open()
        {
            this.gridView1.OptionsSelection.MultiSelectMode = DevExpress.XtraGrid.Views.Grid.GridMultiSelectMode.CheckBoxRowSelect;
            this.gridView1.OptionsSelection.MultiSelect = true;
        }

        void IViewFormPanelBatchAction.Close()
        {
            this.gridView1.OptionsSelection.MultiSelect = false;
        }

        IEnumerable IViewFormPanelBatchAction.GetSelectionCollection()
        {
            return this.gridView1.GetSelectedRows();
        }

        IEnumerable IViewFormPanelBatchAction.GetAllCollection()
        {
            return this.gridView1.GetSelectedRows();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            IMainForm mainForm = SystemCommand.GetService<IMainForm>();
            if (mainForm.ContainsForm("测试表单"))
            {
                var form = mainForm.Forms.First(x => x.Name == "测试表单");
                if (form is INotification notification)
                    notification.ReceiveNotification("测试表单");
            }
        }
    }
}
